/*
 * Selling Partner API for Listings Items
 * The Selling Partner API for Listings Items (Listings Items API) provides programmatic access to selling partner listings on Amazon. Use this API in collaboration with the Selling Partner API for Product Type Definitions, which you use to retrieve the information about Amazon product types needed to use the Listings Items API.  For more information, see the [Listings Items API Use Case Guide](https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-use-case-guide).
 *
 * OpenAPI spec version: 2021-08-01
 *
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */

package software.amazon.spapi.api.listings.items.v2021_08_01;

import com.amazon.SellingPartnerAPIAA.LWAAccessTokenCache;
import com.amazon.SellingPartnerAPIAA.LWAAccessTokenCacheImpl;
import com.amazon.SellingPartnerAPIAA.LWAAuthorizationCredentials;
import com.amazon.SellingPartnerAPIAA.LWAAuthorizationSigner;
import com.amazon.SellingPartnerAPIAA.LWAException;
import com.amazon.SellingPartnerAPIAA.RestrictedDataTokenSigner;
import com.google.gson.reflect.TypeToken;
import io.github.bucket4j.Bucket;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.threeten.bp.OffsetDateTime;
import software.amazon.spapi.ApiCallback;
import software.amazon.spapi.ApiClient;
import software.amazon.spapi.ApiException;
import software.amazon.spapi.ApiResponse;
import software.amazon.spapi.Configuration;
import software.amazon.spapi.Pair;
import software.amazon.spapi.ProgressRequestBody;
import software.amazon.spapi.StringUtil;
import software.amazon.spapi.models.listings.items.v2021_08_01.Item;
import software.amazon.spapi.models.listings.items.v2021_08_01.ItemSearchResults;
import software.amazon.spapi.models.listings.items.v2021_08_01.ListingsItemPatchRequest;
import software.amazon.spapi.models.listings.items.v2021_08_01.ListingsItemPutRequest;
import software.amazon.spapi.models.listings.items.v2021_08_01.ListingsItemSubmissionResponse;

public class ListingsApi {
    private ApiClient apiClient;
    private Boolean disableRateLimiting;

    public ListingsApi(ApiClient apiClient, Boolean disableRateLimiting) {
        this.apiClient = apiClient;
        this.disableRateLimiting = disableRateLimiting;
    }

    private final Configuration config = Configuration.get();

    public final Bucket deleteListingsItemBucket = Bucket.builder()
            .addLimit(config.getLimit("ListingsApi-deleteListingsItem"))
            .build();

    public final Bucket getListingsItemBucket = Bucket.builder()
            .addLimit(config.getLimit("ListingsApi-getListingsItem"))
            .build();

    public final Bucket patchListingsItemBucket = Bucket.builder()
            .addLimit(config.getLimit("ListingsApi-patchListingsItem"))
            .build();

    public final Bucket putListingsItemBucket = Bucket.builder()
            .addLimit(config.getLimit("ListingsApi-putListingsItem"))
            .build();

    public final Bucket searchListingsItemsBucket = Bucket.builder()
            .addLimit(config.getLimit("ListingsApi-searchListingsItems"))
            .build();

    /**
     * Build call for deleteListingsItem
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call deleteListingsItemCall(
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            String issueLocale,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/listings/2021-08-01/items/{sellerId}/{sku}"
                .replaceAll("\\{" + "sellerId" + "\\}", apiClient.escapeString(sellerId.toString()))
                .replaceAll("\\{" + "sku" + "\\}", apiClient.escapeString(sku.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));
        if (issueLocale != null) localVarQueryParams.addAll(apiClient.parameterToPair("issueLocale", issueLocale));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {};

        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "DELETE",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call deleteListingsItemValidateBeforeCall(
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            String issueLocale,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'sellerId' is set
        if (sellerId == null) {
            throw new ApiException("Missing the required parameter 'sellerId' when calling deleteListingsItem(Async)");
        }
        // verify the required parameter 'sku' is set
        if (sku == null) {
            throw new ApiException("Missing the required parameter 'sku' when calling deleteListingsItem(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling deleteListingsItem(Async)");
        }

        return deleteListingsItemCall(sellerId, sku, marketplaceIds, issueLocale, progressRequestListener);
    }

    /**
     * Delete a listings item for a selling partner. **Usage Plan:** | Rate (requests per second) | Burst | | ---- |
     * ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate limits that
     * were applied to the requested operation, when available. The preceding table indicates the default rate and burst
     * values for this operation. Selling partners whose business demands require higher throughput can receive higher
     * rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ListingsItemSubmissionResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ListingsItemSubmissionResponse deleteListingsItem(
            String sellerId, String sku, List<String> marketplaceIds, String issueLocale, String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<ListingsItemSubmissionResponse> resp =
                deleteListingsItemWithHttpInfo(sellerId, sku, marketplaceIds, issueLocale, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Delete a listings item for a selling partner. **Usage Plan:** | Rate (requests per second) | Burst | | ---- |
     * ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate limits that
     * were applied to the requested operation, when available. The preceding table indicates the default rate and burst
     * values for this operation. Selling partners whose business demands require higher throughput can receive higher
     * rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @return ListingsItemSubmissionResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ListingsItemSubmissionResponse deleteListingsItem(
            String sellerId, String sku, List<String> marketplaceIds, String issueLocale)
            throws ApiException, LWAException {
        ApiResponse<ListingsItemSubmissionResponse> resp =
                deleteListingsItemWithHttpInfo(sellerId, sku, marketplaceIds, issueLocale, null);
        return resp.getData();
    }

    /**
     * Delete a listings item for a selling partner. **Usage Plan:** | Rate (requests per second) | Burst | | ---- |
     * ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate limits that
     * were applied to the requested operation, when available. The preceding table indicates the default rate and burst
     * values for this operation. Selling partners whose business demands require higher throughput can receive higher
     * rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;ListingsItemSubmissionResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<ListingsItemSubmissionResponse> deleteListingsItemWithHttpInfo(
            String sellerId, String sku, List<String> marketplaceIds, String issueLocale, String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = deleteListingsItemValidateBeforeCall(sellerId, sku, marketplaceIds, issueLocale, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "ListingsApi-deleteListingsItem");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || deleteListingsItemBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<ListingsItemSubmissionResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("deleteListingsItem operation exceeds rate limit");
    }

    /**
     * Delete a listings item for a selling partner. **Usage Plan:** | Rate (requests per second) | Burst | | ---- |
     * ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate limits that
     * were applied to the requested operation, when available. The preceding table indicates the default rate and burst
     * values for this operation. Selling partners whose business demands require higher throughput can receive higher
     * rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @return ApiResponse&lt;ListingsItemSubmissionResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<ListingsItemSubmissionResponse> deleteListingsItemWithHttpInfo(
            String sellerId, String sku, List<String> marketplaceIds, String issueLocale)
            throws ApiException, LWAException {
        return deleteListingsItemWithHttpInfo(sellerId, sku, marketplaceIds, issueLocale, null);
    }

    /**
     * (asynchronously) Delete a listings item for a selling partner. **Usage Plan:** | Rate (requests per second) |
     * Burst | | ---- | ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan
     * rate limits that were applied to the requested operation, when available. The preceding table indicates the
     * default rate and burst values for this operation. Selling partners whose business demands require higher
     * throughput can receive higher rate and burst values than those shown here. For more information, refer to [Usage
     * Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api)
     * in the Selling Partner API documentation.
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call deleteListingsItemAsync(
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            String issueLocale,
            final ApiCallback<ListingsItemSubmissionResponse> callback)
            throws ApiException, LWAException {
        return deleteListingsItemAsync(sellerId, sku, marketplaceIds, issueLocale, callback, null);
    }
    /**
     * (asynchronously) Delete a listings item for a selling partner. **Usage Plan:** | Rate (requests per second) |
     * Burst | | ---- | ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan
     * rate limits that were applied to the requested operation, when available. The preceding table indicates the
     * default rate and burst values for this operation. Selling partners whose business demands require higher
     * throughput can receive higher rate and burst values than those shown here. For more information, refer to [Usage
     * Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api)
     * in the Selling Partner API documentation.
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call deleteListingsItemAsync(
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            String issueLocale,
            final ApiCallback<ListingsItemSubmissionResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = deleteListingsItemValidateBeforeCall(
                sellerId, sku, marketplaceIds, issueLocale, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "ListingsApi-deleteListingsItem");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || deleteListingsItemBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<ListingsItemSubmissionResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("deleteListingsItem operation exceeds rate limit");
    }
    /**
     * Build call for getListingsItem
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param includedData A comma-delimited list of data sets to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call getListingsItemCall(
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/listings/2021-08-01/items/{sellerId}/{sku}"
                .replaceAll("\\{" + "sellerId" + "\\}", apiClient.escapeString(sellerId.toString()))
                .replaceAll("\\{" + "sku" + "\\}", apiClient.escapeString(sku.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));
        if (issueLocale != null) localVarQueryParams.addAll(apiClient.parameterToPair("issueLocale", issueLocale));
        if (includedData != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "includedData", includedData));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {};

        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "GET",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call getListingsItemValidateBeforeCall(
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'sellerId' is set
        if (sellerId == null) {
            throw new ApiException("Missing the required parameter 'sellerId' when calling getListingsItem(Async)");
        }
        // verify the required parameter 'sku' is set
        if (sku == null) {
            throw new ApiException("Missing the required parameter 'sku' when calling getListingsItem(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling getListingsItem(Async)");
        }

        return getListingsItemCall(sellerId, sku, marketplaceIds, issueLocale, includedData, progressRequestListener);
    }

    /**
     * Returns details about a listings item for a selling partner. **Usage Plan:** | Rate (requests per second) | Burst
     * | | ---- | ---- | | 5 | 10 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate
     * limits that were applied to the requested operation, when available. The preceding table indicates the default
     * rate and burst values for this operation. Selling partners whose business demands require higher throughput can
     * receive higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param includedData A comma-delimited list of data sets to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return Item
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public Item getListingsItem(
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<Item> resp = getListingsItemWithHttpInfo(
                sellerId, sku, marketplaceIds, issueLocale, includedData, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Returns details about a listings item for a selling partner. **Usage Plan:** | Rate (requests per second) | Burst
     * | | ---- | ---- | | 5 | 10 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate
     * limits that were applied to the requested operation, when available. The preceding table indicates the default
     * rate and burst values for this operation. Selling partners whose business demands require higher throughput can
     * receive higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param includedData A comma-delimited list of data sets to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @return Item
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public Item getListingsItem(
            String sellerId, String sku, List<String> marketplaceIds, String issueLocale, List<String> includedData)
            throws ApiException, LWAException {
        ApiResponse<Item> resp =
                getListingsItemWithHttpInfo(sellerId, sku, marketplaceIds, issueLocale, includedData, null);
        return resp.getData();
    }

    /**
     * Returns details about a listings item for a selling partner. **Usage Plan:** | Rate (requests per second) | Burst
     * | | ---- | ---- | | 5 | 10 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate
     * limits that were applied to the requested operation, when available. The preceding table indicates the default
     * rate and burst values for this operation. Selling partners whose business demands require higher throughput can
     * receive higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param includedData A comma-delimited list of data sets to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;Item&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<Item> getListingsItemWithHttpInfo(
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call =
                getListingsItemValidateBeforeCall(sellerId, sku, marketplaceIds, issueLocale, includedData, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "ListingsApi-getListingsItem");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || getListingsItemBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<Item>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("getListingsItem operation exceeds rate limit");
    }

    /**
     * Returns details about a listings item for a selling partner. **Usage Plan:** | Rate (requests per second) | Burst
     * | | ---- | ---- | | 5 | 10 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate
     * limits that were applied to the requested operation, when available. The preceding table indicates the default
     * rate and burst values for this operation. Selling partners whose business demands require higher throughput can
     * receive higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param includedData A comma-delimited list of data sets to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @return ApiResponse&lt;Item&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<Item> getListingsItemWithHttpInfo(
            String sellerId, String sku, List<String> marketplaceIds, String issueLocale, List<String> includedData)
            throws ApiException, LWAException {
        return getListingsItemWithHttpInfo(sellerId, sku, marketplaceIds, issueLocale, includedData, null);
    }

    /**
     * (asynchronously) Returns details about a listings item for a selling partner. **Usage Plan:** | Rate (requests
     * per second) | Burst | | ---- | ---- | | 5 | 10 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns
     * the usage plan rate limits that were applied to the requested operation, when available. The preceding table
     * indicates the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput can receive higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param includedData A comma-delimited list of data sets to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call getListingsItemAsync(
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            final ApiCallback<Item> callback)
            throws ApiException, LWAException {
        return getListingsItemAsync(sellerId, sku, marketplaceIds, issueLocale, includedData, callback, null);
    }
    /**
     * (asynchronously) Returns details about a listings item for a selling partner. **Usage Plan:** | Rate (requests
     * per second) | Burst | | ---- | ---- | | 5 | 10 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns
     * the usage plan rate limits that were applied to the requested operation, when available. The preceding table
     * indicates the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput can receive higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param includedData A comma-delimited list of data sets to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call getListingsItemAsync(
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            final ApiCallback<Item> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = getListingsItemValidateBeforeCall(
                sellerId, sku, marketplaceIds, issueLocale, includedData, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "ListingsApi-getListingsItem");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || getListingsItemBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<Item>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("getListingsItem operation exceeds rate limit");
    }
    /**
     * Build call for patchListingsItem
     *
     * @param body The request body schema for the &#x60;patchListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call patchListingsItemCall(
            ListingsItemPatchRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/listings/2021-08-01/items/{sellerId}/{sku}"
                .replaceAll("\\{" + "sellerId" + "\\}", apiClient.escapeString(sellerId.toString()))
                .replaceAll("\\{" + "sku" + "\\}", apiClient.escapeString(sku.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));
        if (includedData != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "includedData", includedData));
        if (mode != null) localVarQueryParams.addAll(apiClient.parameterToPair("mode", mode));
        if (issueLocale != null) localVarQueryParams.addAll(apiClient.parameterToPair("issueLocale", issueLocale));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {"application/json"};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "PATCH",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call patchListingsItemValidateBeforeCall(
            ListingsItemPatchRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException("Missing the required parameter 'body' when calling patchListingsItem(Async)");
        }
        // verify the required parameter 'sellerId' is set
        if (sellerId == null) {
            throw new ApiException("Missing the required parameter 'sellerId' when calling patchListingsItem(Async)");
        }
        // verify the required parameter 'sku' is set
        if (sku == null) {
            throw new ApiException("Missing the required parameter 'sku' when calling patchListingsItem(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling patchListingsItem(Async)");
        }

        return patchListingsItemCall(
                body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, progressRequestListener);
    }

    /**
     * Partially update (patch) a listings item for a selling partner. Only top-level listings item attributes can be
     * patched. Patching nested attributes is not supported. **Usage Plan:** | Rate (requests per second) | Burst | |
     * ---- | ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate limits
     * that were applied to the requested operation, when available. The preceding table indicates the default rate and
     * burst values for this operation. Selling partners whose business demands require higher throughput can receive
     * higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param body The request body schema for the &#x60;patchListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ListingsItemSubmissionResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ListingsItemSubmissionResponse patchListingsItem(
            ListingsItemPatchRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale,
            String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<ListingsItemSubmissionResponse> resp = patchListingsItemWithHttpInfo(
                body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Partially update (patch) a listings item for a selling partner. Only top-level listings item attributes can be
     * patched. Patching nested attributes is not supported. **Usage Plan:** | Rate (requests per second) | Burst | |
     * ---- | ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate limits
     * that were applied to the requested operation, when available. The preceding table indicates the default rate and
     * burst values for this operation. Selling partners whose business demands require higher throughput can receive
     * higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param body The request body schema for the &#x60;patchListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @return ListingsItemSubmissionResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ListingsItemSubmissionResponse patchListingsItem(
            ListingsItemPatchRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale)
            throws ApiException, LWAException {
        ApiResponse<ListingsItemSubmissionResponse> resp = patchListingsItemWithHttpInfo(
                body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, null);
        return resp.getData();
    }

    /**
     * Partially update (patch) a listings item for a selling partner. Only top-level listings item attributes can be
     * patched. Patching nested attributes is not supported. **Usage Plan:** | Rate (requests per second) | Burst | |
     * ---- | ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate limits
     * that were applied to the requested operation, when available. The preceding table indicates the default rate and
     * burst values for this operation. Selling partners whose business demands require higher throughput can receive
     * higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param body The request body schema for the &#x60;patchListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;ListingsItemSubmissionResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<ListingsItemSubmissionResponse> patchListingsItemWithHttpInfo(
            ListingsItemPatchRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale,
            String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = patchListingsItemValidateBeforeCall(
                body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "ListingsApi-patchListingsItem");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || patchListingsItemBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<ListingsItemSubmissionResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("patchListingsItem operation exceeds rate limit");
    }

    /**
     * Partially update (patch) a listings item for a selling partner. Only top-level listings item attributes can be
     * patched. Patching nested attributes is not supported. **Usage Plan:** | Rate (requests per second) | Burst | |
     * ---- | ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate limits
     * that were applied to the requested operation, when available. The preceding table indicates the default rate and
     * burst values for this operation. Selling partners whose business demands require higher throughput can receive
     * higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param body The request body schema for the &#x60;patchListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @return ApiResponse&lt;ListingsItemSubmissionResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<ListingsItemSubmissionResponse> patchListingsItemWithHttpInfo(
            ListingsItemPatchRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale)
            throws ApiException, LWAException {
        return patchListingsItemWithHttpInfo(
                body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, null);
    }

    /**
     * (asynchronously) Partially update (patch) a listings item for a selling partner. Only top-level listings item
     * attributes can be patched. Patching nested attributes is not supported. **Usage Plan:** | Rate (requests per
     * second) | Burst | | ---- | ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the
     * usage plan rate limits that were applied to the requested operation, when available. The preceding table
     * indicates the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput can receive higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param body The request body schema for the &#x60;patchListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call patchListingsItemAsync(
            ListingsItemPatchRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale,
            final ApiCallback<ListingsItemSubmissionResponse> callback)
            throws ApiException, LWAException {
        return patchListingsItemAsync(
                body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, callback, null);
    }
    /**
     * (asynchronously) Partially update (patch) a listings item for a selling partner. Only top-level listings item
     * attributes can be patched. Patching nested attributes is not supported. **Usage Plan:** | Rate (requests per
     * second) | Burst | | ---- | ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the
     * usage plan rate limits that were applied to the requested operation, when available. The preceding table
     * indicates the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput can receive higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param body The request body schema for the &#x60;patchListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call patchListingsItemAsync(
            ListingsItemPatchRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale,
            final ApiCallback<ListingsItemSubmissionResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = patchListingsItemValidateBeforeCall(
                body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "ListingsApi-patchListingsItem");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || patchListingsItemBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<ListingsItemSubmissionResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("patchListingsItem operation exceeds rate limit");
    }
    /**
     * Build call for putListingsItem
     *
     * @param body The request body schema for the &#x60;putListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call putListingsItemCall(
            ListingsItemPutRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/listings/2021-08-01/items/{sellerId}/{sku}"
                .replaceAll("\\{" + "sellerId" + "\\}", apiClient.escapeString(sellerId.toString()))
                .replaceAll("\\{" + "sku" + "\\}", apiClient.escapeString(sku.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));
        if (includedData != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "includedData", includedData));
        if (mode != null) localVarQueryParams.addAll(apiClient.parameterToPair("mode", mode));
        if (issueLocale != null) localVarQueryParams.addAll(apiClient.parameterToPair("issueLocale", issueLocale));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {"application/json"};
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "PUT",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call putListingsItemValidateBeforeCall(
            ListingsItemPutRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException("Missing the required parameter 'body' when calling putListingsItem(Async)");
        }
        // verify the required parameter 'sellerId' is set
        if (sellerId == null) {
            throw new ApiException("Missing the required parameter 'sellerId' when calling putListingsItem(Async)");
        }
        // verify the required parameter 'sku' is set
        if (sku == null) {
            throw new ApiException("Missing the required parameter 'sku' when calling putListingsItem(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling putListingsItem(Async)");
        }

        return putListingsItemCall(
                body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, progressRequestListener);
    }

    /**
     * Creates a new or fully-updates an existing listings item for a selling partner. **Usage Plan:** | Rate (requests
     * per second) | Burst | | ---- | ---- | | 5 | 10 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns
     * the usage plan rate limits that were applied to the requested operation, when available. The preceding table
     * indicates the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput can receive higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param body The request body schema for the &#x60;putListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ListingsItemSubmissionResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ListingsItemSubmissionResponse putListingsItem(
            ListingsItemPutRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale,
            String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<ListingsItemSubmissionResponse> resp = putListingsItemWithHttpInfo(
                body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, restrictedDataToken);
        return resp.getData();
    }

    /**
     * Creates a new or fully-updates an existing listings item for a selling partner. **Usage Plan:** | Rate (requests
     * per second) | Burst | | ---- | ---- | | 5 | 10 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns
     * the usage plan rate limits that were applied to the requested operation, when available. The preceding table
     * indicates the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput can receive higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param body The request body schema for the &#x60;putListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @return ListingsItemSubmissionResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ListingsItemSubmissionResponse putListingsItem(
            ListingsItemPutRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale)
            throws ApiException, LWAException {
        ApiResponse<ListingsItemSubmissionResponse> resp =
                putListingsItemWithHttpInfo(body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, null);
        return resp.getData();
    }

    /**
     * Creates a new or fully-updates an existing listings item for a selling partner. **Usage Plan:** | Rate (requests
     * per second) | Burst | | ---- | ---- | | 5 | 10 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns
     * the usage plan rate limits that were applied to the requested operation, when available. The preceding table
     * indicates the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput can receive higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param body The request body schema for the &#x60;putListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;ListingsItemSubmissionResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<ListingsItemSubmissionResponse> putListingsItemWithHttpInfo(
            ListingsItemPutRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale,
            String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = putListingsItemValidateBeforeCall(
                body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "ListingsApi-putListingsItem");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || putListingsItemBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<ListingsItemSubmissionResponse>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("putListingsItem operation exceeds rate limit");
    }

    /**
     * Creates a new or fully-updates an existing listings item for a selling partner. **Usage Plan:** | Rate (requests
     * per second) | Burst | | ---- | ---- | | 5 | 10 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns
     * the usage plan rate limits that were applied to the requested operation, when available. The preceding table
     * indicates the default rate and burst values for this operation. Selling partners whose business demands require
     * higher throughput can receive higher rate and burst values than those shown here. For more information, refer to
     * [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param body The request body schema for the &#x60;putListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @return ApiResponse&lt;ListingsItemSubmissionResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<ListingsItemSubmissionResponse> putListingsItemWithHttpInfo(
            ListingsItemPutRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale)
            throws ApiException, LWAException {
        return putListingsItemWithHttpInfo(body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, null);
    }

    /**
     * (asynchronously) Creates a new or fully-updates an existing listings item for a selling partner. **Usage Plan:**
     * | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 10 | The &#x60;x-amzn-RateLimit-Limit&#x60; response
     * header returns the usage plan rate limits that were applied to the requested operation, when available. The
     * preceding table indicates the default rate and burst values for this operation. Selling partners whose business
     * demands require higher throughput can receive higher rate and burst values than those shown here. For more
     * information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param body The request body schema for the &#x60;putListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call putListingsItemAsync(
            ListingsItemPutRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale,
            final ApiCallback<ListingsItemSubmissionResponse> callback)
            throws ApiException, LWAException {
        return putListingsItemAsync(
                body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, callback, null);
    }
    /**
     * (asynchronously) Creates a new or fully-updates an existing listings item for a selling partner. **Usage Plan:**
     * | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 10 | The &#x60;x-amzn-RateLimit-Limit&#x60; response
     * header returns the usage plan rate limits that were applied to the requested operation, when available. The
     * preceding table indicates the default rate and burst values for this operation. Selling partners whose business
     * demands require higher throughput can receive higher rate and burst values than those shown here. For more
     * information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api) in the Selling
     * Partner API documentation.
     *
     * @param body The request body schema for the &#x60;putListingsItem&#x60; operation. (required)
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param sku A selling partner provided identifier for an Amazon listing. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param includedData A comma-delimited list of data sets to include in the response. Default: &#x60;issues&#x60;.
     *     (optional)
     * @param mode The mode of operation for the request. (optional)
     * @param issueLocale A locale for localization of issues. When not provided, the default language code of the first
     *     marketplace is used. Examples: &#x60;en_US&#x60;, &#x60;fr_CA&#x60;, &#x60;fr_FR&#x60;. Localized messages
     *     default to &#x60;en_US&#x60; when a localization is not available in the specified locale. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call putListingsItemAsync(
            ListingsItemPutRequest body,
            String sellerId,
            String sku,
            List<String> marketplaceIds,
            List<String> includedData,
            String mode,
            String issueLocale,
            final ApiCallback<ListingsItemSubmissionResponse> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = putListingsItemValidateBeforeCall(
                body, sellerId, sku, marketplaceIds, includedData, mode, issueLocale, progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "ListingsApi-putListingsItem");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || putListingsItemBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<ListingsItemSubmissionResponse>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("putListingsItem operation exceeds rate limit");
    }
    /**
     * Build call for searchListingsItems
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale that is used to localize issues. When not provided, the default language code of the
     *     first marketplace is used. Examples: \&quot;en_US\&quot;, \&quot;fr_CA\&quot;, \&quot;fr_FR\&quot;. When a
     *     localization is not available in the specified locale, localized messages default to \&quot;en_US\&quot;.
     *     (optional)
     * @param includedData A comma-delimited list of datasets that you want to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @param identifiers A comma-delimited list of product identifiers that you can use to search for listings items.
     *     **Note**: 1. This is required when you specify &#x60;identifiersType&#x60;. 2. You cannot use
     *     &#x27;identifiers&#x27; if you specify &#x60;variationParentSku&#x60; or &#x60;packageHierarchySku&#x60;.
     *     (optional)
     * @param identifiersType A type of product identifiers that you can use to search for listings items. **Note**:
     *     This is required when &#x60;identifiers&#x60; is provided. (optional)
     * @param variationParentSku Filters results to include listing items that are variation children of the specified
     *     SKU. **Note**: You cannot use &#x60;variationParentSku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;packageHierarchySku&#x60; in your request. (optional)
     * @param packageHierarchySku Filter results to include listing items that contain or are contained by the specified
     *     SKU. **Note**: You cannot use &#x60;packageHierarchySku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;variationParentSku&#x60; in your request. (optional)
     * @param createdAfter A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param createdBefore A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedAfter A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedBefore A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param withIssueSeverity Filter results to include only listing items that have issues that match one or more of
     *     the specified severity levels. (optional)
     * @param withStatus Filter results to include only listing items that have the specified status. (optional)
     * @param withoutStatus Filter results to include only listing items that don&#x27;t contain the specified statuses.
     *     (optional)
     * @param sortBy An attribute by which to sort the returned listing items. (optional, default to lastUpdatedDate)
     * @param sortOrder The order in which to sort the result items. (optional, default to DESC)
     * @param pageSize The number of results that you want to include on each page. (optional, default to 10)
     * @param pageToken A token that you can use to fetch a specific page when there are multiple pages of results.
     *     (optional)
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    private okhttp3.Call searchListingsItemsCall(
            String sellerId,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            List<String> identifiers,
            String identifiersType,
            String variationParentSku,
            String packageHierarchySku,
            OffsetDateTime createdAfter,
            OffsetDateTime createdBefore,
            OffsetDateTime lastUpdatedAfter,
            OffsetDateTime lastUpdatedBefore,
            List<String> withIssueSeverity,
            List<String> withStatus,
            List<String> withoutStatus,
            String sortBy,
            String sortOrder,
            Integer pageSize,
            String pageToken,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/listings/2021-08-01/items/{sellerId}"
                .replaceAll("\\{" + "sellerId" + "\\}", apiClient.escapeString(sellerId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (marketplaceIds != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "marketplaceIds", marketplaceIds));
        if (issueLocale != null) localVarQueryParams.addAll(apiClient.parameterToPair("issueLocale", issueLocale));
        if (includedData != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "includedData", includedData));
        if (identifiers != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "identifiers", identifiers));
        if (identifiersType != null)
            localVarQueryParams.addAll(apiClient.parameterToPair("identifiersType", identifiersType));
        if (variationParentSku != null)
            localVarQueryParams.addAll(apiClient.parameterToPair("variationParentSku", variationParentSku));
        if (packageHierarchySku != null)
            localVarQueryParams.addAll(apiClient.parameterToPair("packageHierarchySku", packageHierarchySku));
        if (createdAfter != null) localVarQueryParams.addAll(apiClient.parameterToPair("createdAfter", createdAfter));
        if (createdBefore != null)
            localVarQueryParams.addAll(apiClient.parameterToPair("createdBefore", createdBefore));
        if (lastUpdatedAfter != null)
            localVarQueryParams.addAll(apiClient.parameterToPair("lastUpdatedAfter", lastUpdatedAfter));
        if (lastUpdatedBefore != null)
            localVarQueryParams.addAll(apiClient.parameterToPair("lastUpdatedBefore", lastUpdatedBefore));
        if (withIssueSeverity != null)
            localVarCollectionQueryParams.addAll(
                    apiClient.parameterToPairs("csv", "withIssueSeverity", withIssueSeverity));
        if (withStatus != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "withStatus", withStatus));
        if (withoutStatus != null)
            localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "withoutStatus", withoutStatus));
        if (sortBy != null) localVarQueryParams.addAll(apiClient.parameterToPair("sortBy", sortBy));
        if (sortOrder != null) localVarQueryParams.addAll(apiClient.parameterToPair("sortOrder", sortOrder));
        if (pageSize != null) localVarQueryParams.addAll(apiClient.parameterToPair("pageSize", pageSize));
        if (pageToken != null) localVarQueryParams.addAll(apiClient.parameterToPair("pageToken", pageToken));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {"application/json"};
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {};

        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        return apiClient.buildCall(
                localVarPath,
                "GET",
                localVarQueryParams,
                localVarCollectionQueryParams,
                localVarPostBody,
                localVarHeaderParams,
                localVarFormParams,
                progressRequestListener);
    }

    private okhttp3.Call searchListingsItemsValidateBeforeCall(
            String sellerId,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            List<String> identifiers,
            String identifiersType,
            String variationParentSku,
            String packageHierarchySku,
            OffsetDateTime createdAfter,
            OffsetDateTime createdBefore,
            OffsetDateTime lastUpdatedAfter,
            OffsetDateTime lastUpdatedBefore,
            List<String> withIssueSeverity,
            List<String> withStatus,
            List<String> withoutStatus,
            String sortBy,
            String sortOrder,
            Integer pageSize,
            String pageToken,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener)
            throws ApiException, LWAException {
        // verify the required parameter 'sellerId' is set
        if (sellerId == null) {
            throw new ApiException("Missing the required parameter 'sellerId' when calling searchListingsItems(Async)");
        }
        // verify the required parameter 'marketplaceIds' is set
        if (marketplaceIds == null) {
            throw new ApiException(
                    "Missing the required parameter 'marketplaceIds' when calling searchListingsItems(Async)");
        }

        return searchListingsItemsCall(
                sellerId,
                marketplaceIds,
                issueLocale,
                includedData,
                identifiers,
                identifiersType,
                variationParentSku,
                packageHierarchySku,
                createdAfter,
                createdBefore,
                lastUpdatedAfter,
                lastUpdatedBefore,
                withIssueSeverity,
                withStatus,
                withoutStatus,
                sortBy,
                sortOrder,
                pageSize,
                pageToken,
                progressRequestListener);
    }

    /**
     * Search for and return a list of selling partner listings items and their respective details. **Usage Plan:** |
     * Rate (requests per second) | Burst | | ---- | ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response
     * header returns the usage plan rate limits that are applied to the requested operation, when available. The
     * preceding table contains the default rate and burst values for this operation. Selling partners whose business
     * demands require higher throughput might have higher rate and burst values than those shown here. For more
     * information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale that is used to localize issues. When not provided, the default language code of the
     *     first marketplace is used. Examples: \&quot;en_US\&quot;, \&quot;fr_CA\&quot;, \&quot;fr_FR\&quot;. When a
     *     localization is not available in the specified locale, localized messages default to \&quot;en_US\&quot;.
     *     (optional)
     * @param includedData A comma-delimited list of datasets that you want to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @param identifiers A comma-delimited list of product identifiers that you can use to search for listings items.
     *     **Note**: 1. This is required when you specify &#x60;identifiersType&#x60;. 2. You cannot use
     *     &#x27;identifiers&#x27; if you specify &#x60;variationParentSku&#x60; or &#x60;packageHierarchySku&#x60;.
     *     (optional)
     * @param identifiersType A type of product identifiers that you can use to search for listings items. **Note**:
     *     This is required when &#x60;identifiers&#x60; is provided. (optional)
     * @param variationParentSku Filters results to include listing items that are variation children of the specified
     *     SKU. **Note**: You cannot use &#x60;variationParentSku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;packageHierarchySku&#x60; in your request. (optional)
     * @param packageHierarchySku Filter results to include listing items that contain or are contained by the specified
     *     SKU. **Note**: You cannot use &#x60;packageHierarchySku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;variationParentSku&#x60; in your request. (optional)
     * @param createdAfter A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param createdBefore A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedAfter A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedBefore A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param withIssueSeverity Filter results to include only listing items that have issues that match one or more of
     *     the specified severity levels. (optional)
     * @param withStatus Filter results to include only listing items that have the specified status. (optional)
     * @param withoutStatus Filter results to include only listing items that don&#x27;t contain the specified statuses.
     *     (optional)
     * @param sortBy An attribute by which to sort the returned listing items. (optional, default to lastUpdatedDate)
     * @param sortOrder The order in which to sort the result items. (optional, default to DESC)
     * @param pageSize The number of results that you want to include on each page. (optional, default to 10)
     * @param pageToken A token that you can use to fetch a specific page when there are multiple pages of results.
     *     (optional)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ItemSearchResults
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ItemSearchResults searchListingsItems(
            String sellerId,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            List<String> identifiers,
            String identifiersType,
            String variationParentSku,
            String packageHierarchySku,
            OffsetDateTime createdAfter,
            OffsetDateTime createdBefore,
            OffsetDateTime lastUpdatedAfter,
            OffsetDateTime lastUpdatedBefore,
            List<String> withIssueSeverity,
            List<String> withStatus,
            List<String> withoutStatus,
            String sortBy,
            String sortOrder,
            Integer pageSize,
            String pageToken,
            String restrictedDataToken)
            throws ApiException, LWAException {
        ApiResponse<ItemSearchResults> resp = searchListingsItemsWithHttpInfo(
                sellerId,
                marketplaceIds,
                issueLocale,
                includedData,
                identifiers,
                identifiersType,
                variationParentSku,
                packageHierarchySku,
                createdAfter,
                createdBefore,
                lastUpdatedAfter,
                lastUpdatedBefore,
                withIssueSeverity,
                withStatus,
                withoutStatus,
                sortBy,
                sortOrder,
                pageSize,
                pageToken,
                restrictedDataToken);
        return resp.getData();
    }

    /**
     * Search for and return a list of selling partner listings items and their respective details. **Usage Plan:** |
     * Rate (requests per second) | Burst | | ---- | ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response
     * header returns the usage plan rate limits that are applied to the requested operation, when available. The
     * preceding table contains the default rate and burst values for this operation. Selling partners whose business
     * demands require higher throughput might have higher rate and burst values than those shown here. For more
     * information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale that is used to localize issues. When not provided, the default language code of the
     *     first marketplace is used. Examples: \&quot;en_US\&quot;, \&quot;fr_CA\&quot;, \&quot;fr_FR\&quot;. When a
     *     localization is not available in the specified locale, localized messages default to \&quot;en_US\&quot;.
     *     (optional)
     * @param includedData A comma-delimited list of datasets that you want to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @param identifiers A comma-delimited list of product identifiers that you can use to search for listings items.
     *     **Note**: 1. This is required when you specify &#x60;identifiersType&#x60;. 2. You cannot use
     *     &#x27;identifiers&#x27; if you specify &#x60;variationParentSku&#x60; or &#x60;packageHierarchySku&#x60;.
     *     (optional)
     * @param identifiersType A type of product identifiers that you can use to search for listings items. **Note**:
     *     This is required when &#x60;identifiers&#x60; is provided. (optional)
     * @param variationParentSku Filters results to include listing items that are variation children of the specified
     *     SKU. **Note**: You cannot use &#x60;variationParentSku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;packageHierarchySku&#x60; in your request. (optional)
     * @param packageHierarchySku Filter results to include listing items that contain or are contained by the specified
     *     SKU. **Note**: You cannot use &#x60;packageHierarchySku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;variationParentSku&#x60; in your request. (optional)
     * @param createdAfter A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param createdBefore A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedAfter A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedBefore A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param withIssueSeverity Filter results to include only listing items that have issues that match one or more of
     *     the specified severity levels. (optional)
     * @param withStatus Filter results to include only listing items that have the specified status. (optional)
     * @param withoutStatus Filter results to include only listing items that don&#x27;t contain the specified statuses.
     *     (optional)
     * @param sortBy An attribute by which to sort the returned listing items. (optional, default to lastUpdatedDate)
     * @param sortOrder The order in which to sort the result items. (optional, default to DESC)
     * @param pageSize The number of results that you want to include on each page. (optional, default to 10)
     * @param pageToken A token that you can use to fetch a specific page when there are multiple pages of results.
     *     (optional)
     * @return ItemSearchResults
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ItemSearchResults searchListingsItems(
            String sellerId,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            List<String> identifiers,
            String identifiersType,
            String variationParentSku,
            String packageHierarchySku,
            OffsetDateTime createdAfter,
            OffsetDateTime createdBefore,
            OffsetDateTime lastUpdatedAfter,
            OffsetDateTime lastUpdatedBefore,
            List<String> withIssueSeverity,
            List<String> withStatus,
            List<String> withoutStatus,
            String sortBy,
            String sortOrder,
            Integer pageSize,
            String pageToken)
            throws ApiException, LWAException {
        ApiResponse<ItemSearchResults> resp = searchListingsItemsWithHttpInfo(
                sellerId,
                marketplaceIds,
                issueLocale,
                includedData,
                identifiers,
                identifiersType,
                variationParentSku,
                packageHierarchySku,
                createdAfter,
                createdBefore,
                lastUpdatedAfter,
                lastUpdatedBefore,
                withIssueSeverity,
                withStatus,
                withoutStatus,
                sortBy,
                sortOrder,
                pageSize,
                pageToken,
                null);
        return resp.getData();
    }

    /**
     * Search for and return a list of selling partner listings items and their respective details. **Usage Plan:** |
     * Rate (requests per second) | Burst | | ---- | ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response
     * header returns the usage plan rate limits that are applied to the requested operation, when available. The
     * preceding table contains the default rate and burst values for this operation. Selling partners whose business
     * demands require higher throughput might have higher rate and burst values than those shown here. For more
     * information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale that is used to localize issues. When not provided, the default language code of the
     *     first marketplace is used. Examples: \&quot;en_US\&quot;, \&quot;fr_CA\&quot;, \&quot;fr_FR\&quot;. When a
     *     localization is not available in the specified locale, localized messages default to \&quot;en_US\&quot;.
     *     (optional)
     * @param includedData A comma-delimited list of datasets that you want to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @param identifiers A comma-delimited list of product identifiers that you can use to search for listings items.
     *     **Note**: 1. This is required when you specify &#x60;identifiersType&#x60;. 2. You cannot use
     *     &#x27;identifiers&#x27; if you specify &#x60;variationParentSku&#x60; or &#x60;packageHierarchySku&#x60;.
     *     (optional)
     * @param identifiersType A type of product identifiers that you can use to search for listings items. **Note**:
     *     This is required when &#x60;identifiers&#x60; is provided. (optional)
     * @param variationParentSku Filters results to include listing items that are variation children of the specified
     *     SKU. **Note**: You cannot use &#x60;variationParentSku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;packageHierarchySku&#x60; in your request. (optional)
     * @param packageHierarchySku Filter results to include listing items that contain or are contained by the specified
     *     SKU. **Note**: You cannot use &#x60;packageHierarchySku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;variationParentSku&#x60; in your request. (optional)
     * @param createdAfter A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param createdBefore A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedAfter A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedBefore A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param withIssueSeverity Filter results to include only listing items that have issues that match one or more of
     *     the specified severity levels. (optional)
     * @param withStatus Filter results to include only listing items that have the specified status. (optional)
     * @param withoutStatus Filter results to include only listing items that don&#x27;t contain the specified statuses.
     *     (optional)
     * @param sortBy An attribute by which to sort the returned listing items. (optional, default to lastUpdatedDate)
     * @param sortOrder The order in which to sort the result items. (optional, default to DESC)
     * @param pageSize The number of results that you want to include on each page. (optional, default to 10)
     * @param pageToken A token that you can use to fetch a specific page when there are multiple pages of results.
     *     (optional)
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return ApiResponse&lt;ItemSearchResults&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<ItemSearchResults> searchListingsItemsWithHttpInfo(
            String sellerId,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            List<String> identifiers,
            String identifiersType,
            String variationParentSku,
            String packageHierarchySku,
            OffsetDateTime createdAfter,
            OffsetDateTime createdBefore,
            OffsetDateTime lastUpdatedAfter,
            OffsetDateTime lastUpdatedBefore,
            List<String> withIssueSeverity,
            List<String> withStatus,
            List<String> withoutStatus,
            String sortBy,
            String sortOrder,
            Integer pageSize,
            String pageToken,
            String restrictedDataToken)
            throws ApiException, LWAException {
        okhttp3.Call call = searchListingsItemsValidateBeforeCall(
                sellerId,
                marketplaceIds,
                issueLocale,
                includedData,
                identifiers,
                identifiersType,
                variationParentSku,
                packageHierarchySku,
                createdAfter,
                createdBefore,
                lastUpdatedAfter,
                lastUpdatedBefore,
                withIssueSeverity,
                withStatus,
                withoutStatus,
                sortBy,
                sortOrder,
                pageSize,
                pageToken,
                null);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "ListingsApi-searchListingsItems");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || searchListingsItemsBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<ItemSearchResults>() {}.getType();
            return apiClient.execute(call, localVarReturnType);
        } else throw new ApiException.RateLimitExceeded("searchListingsItems operation exceeds rate limit");
    }

    /**
     * Search for and return a list of selling partner listings items and their respective details. **Usage Plan:** |
     * Rate (requests per second) | Burst | | ---- | ---- | | 5 | 5 | The &#x60;x-amzn-RateLimit-Limit&#x60; response
     * header returns the usage plan rate limits that are applied to the requested operation, when available. The
     * preceding table contains the default rate and burst values for this operation. Selling partners whose business
     * demands require higher throughput might have higher rate and burst values than those shown here. For more
     * information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale that is used to localize issues. When not provided, the default language code of the
     *     first marketplace is used. Examples: \&quot;en_US\&quot;, \&quot;fr_CA\&quot;, \&quot;fr_FR\&quot;. When a
     *     localization is not available in the specified locale, localized messages default to \&quot;en_US\&quot;.
     *     (optional)
     * @param includedData A comma-delimited list of datasets that you want to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @param identifiers A comma-delimited list of product identifiers that you can use to search for listings items.
     *     **Note**: 1. This is required when you specify &#x60;identifiersType&#x60;. 2. You cannot use
     *     &#x27;identifiers&#x27; if you specify &#x60;variationParentSku&#x60; or &#x60;packageHierarchySku&#x60;.
     *     (optional)
     * @param identifiersType A type of product identifiers that you can use to search for listings items. **Note**:
     *     This is required when &#x60;identifiers&#x60; is provided. (optional)
     * @param variationParentSku Filters results to include listing items that are variation children of the specified
     *     SKU. **Note**: You cannot use &#x60;variationParentSku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;packageHierarchySku&#x60; in your request. (optional)
     * @param packageHierarchySku Filter results to include listing items that contain or are contained by the specified
     *     SKU. **Note**: You cannot use &#x60;packageHierarchySku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;variationParentSku&#x60; in your request. (optional)
     * @param createdAfter A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param createdBefore A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedAfter A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedBefore A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param withIssueSeverity Filter results to include only listing items that have issues that match one or more of
     *     the specified severity levels. (optional)
     * @param withStatus Filter results to include only listing items that have the specified status. (optional)
     * @param withoutStatus Filter results to include only listing items that don&#x27;t contain the specified statuses.
     *     (optional)
     * @param sortBy An attribute by which to sort the returned listing items. (optional, default to lastUpdatedDate)
     * @param sortOrder The order in which to sort the result items. (optional, default to DESC)
     * @param pageSize The number of results that you want to include on each page. (optional, default to 10)
     * @param pageToken A token that you can use to fetch a specific page when there are multiple pages of results.
     *     (optional)
     * @return ApiResponse&lt;ItemSearchResults&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public ApiResponse<ItemSearchResults> searchListingsItemsWithHttpInfo(
            String sellerId,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            List<String> identifiers,
            String identifiersType,
            String variationParentSku,
            String packageHierarchySku,
            OffsetDateTime createdAfter,
            OffsetDateTime createdBefore,
            OffsetDateTime lastUpdatedAfter,
            OffsetDateTime lastUpdatedBefore,
            List<String> withIssueSeverity,
            List<String> withStatus,
            List<String> withoutStatus,
            String sortBy,
            String sortOrder,
            Integer pageSize,
            String pageToken)
            throws ApiException, LWAException {
        return searchListingsItemsWithHttpInfo(
                sellerId,
                marketplaceIds,
                issueLocale,
                includedData,
                identifiers,
                identifiersType,
                variationParentSku,
                packageHierarchySku,
                createdAfter,
                createdBefore,
                lastUpdatedAfter,
                lastUpdatedBefore,
                withIssueSeverity,
                withStatus,
                withoutStatus,
                sortBy,
                sortOrder,
                pageSize,
                pageToken,
                null);
    }

    /**
     * (asynchronously) Search for and return a list of selling partner listings items and their respective details.
     * **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate limits that are applied to the
     * requested operation, when available. The preceding table contains the default rate and burst values for this
     * operation. Selling partners whose business demands require higher throughput might have higher rate and burst
     * values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale that is used to localize issues. When not provided, the default language code of the
     *     first marketplace is used. Examples: \&quot;en_US\&quot;, \&quot;fr_CA\&quot;, \&quot;fr_FR\&quot;. When a
     *     localization is not available in the specified locale, localized messages default to \&quot;en_US\&quot;.
     *     (optional)
     * @param includedData A comma-delimited list of datasets that you want to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @param identifiers A comma-delimited list of product identifiers that you can use to search for listings items.
     *     **Note**: 1. This is required when you specify &#x60;identifiersType&#x60;. 2. You cannot use
     *     &#x27;identifiers&#x27; if you specify &#x60;variationParentSku&#x60; or &#x60;packageHierarchySku&#x60;.
     *     (optional)
     * @param identifiersType A type of product identifiers that you can use to search for listings items. **Note**:
     *     This is required when &#x60;identifiers&#x60; is provided. (optional)
     * @param variationParentSku Filters results to include listing items that are variation children of the specified
     *     SKU. **Note**: You cannot use &#x60;variationParentSku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;packageHierarchySku&#x60; in your request. (optional)
     * @param packageHierarchySku Filter results to include listing items that contain or are contained by the specified
     *     SKU. **Note**: You cannot use &#x60;packageHierarchySku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;variationParentSku&#x60; in your request. (optional)
     * @param createdAfter A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param createdBefore A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedAfter A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedBefore A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param withIssueSeverity Filter results to include only listing items that have issues that match one or more of
     *     the specified severity levels. (optional)
     * @param withStatus Filter results to include only listing items that have the specified status. (optional)
     * @param withoutStatus Filter results to include only listing items that don&#x27;t contain the specified statuses.
     *     (optional)
     * @param sortBy An attribute by which to sort the returned listing items. (optional, default to lastUpdatedDate)
     * @param sortOrder The order in which to sort the result items. (optional, default to DESC)
     * @param pageSize The number of results that you want to include on each page. (optional, default to 10)
     * @param pageToken A token that you can use to fetch a specific page when there are multiple pages of results.
     *     (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call searchListingsItemsAsync(
            String sellerId,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            List<String> identifiers,
            String identifiersType,
            String variationParentSku,
            String packageHierarchySku,
            OffsetDateTime createdAfter,
            OffsetDateTime createdBefore,
            OffsetDateTime lastUpdatedAfter,
            OffsetDateTime lastUpdatedBefore,
            List<String> withIssueSeverity,
            List<String> withStatus,
            List<String> withoutStatus,
            String sortBy,
            String sortOrder,
            Integer pageSize,
            String pageToken,
            final ApiCallback<ItemSearchResults> callback)
            throws ApiException, LWAException {
        return searchListingsItemsAsync(
                sellerId,
                marketplaceIds,
                issueLocale,
                includedData,
                identifiers,
                identifiersType,
                variationParentSku,
                packageHierarchySku,
                createdAfter,
                createdBefore,
                lastUpdatedAfter,
                lastUpdatedBefore,
                withIssueSeverity,
                withStatus,
                withoutStatus,
                sortBy,
                sortOrder,
                pageSize,
                pageToken,
                callback,
                null);
    }
    /**
     * (asynchronously) Search for and return a list of selling partner listings items and their respective details.
     * **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 5 | The
     * &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate limits that are applied to the
     * requested operation, when available. The preceding table contains the default rate and burst values for this
     * operation. Selling partners whose business demands require higher throughput might have higher rate and burst
     * values than those shown here. For more information, refer to [Usage Plans and Rate
     * Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
     *
     * @param sellerId A selling partner identifier, such as a merchant account or vendor code. (required)
     * @param marketplaceIds A comma-delimited list of Amazon marketplace identifiers for the request. (required)
     * @param issueLocale A locale that is used to localize issues. When not provided, the default language code of the
     *     first marketplace is used. Examples: \&quot;en_US\&quot;, \&quot;fr_CA\&quot;, \&quot;fr_FR\&quot;. When a
     *     localization is not available in the specified locale, localized messages default to \&quot;en_US\&quot;.
     *     (optional)
     * @param includedData A comma-delimited list of datasets that you want to include in the response. Default:
     *     &#x60;summaries&#x60;. (optional)
     * @param identifiers A comma-delimited list of product identifiers that you can use to search for listings items.
     *     **Note**: 1. This is required when you specify &#x60;identifiersType&#x60;. 2. You cannot use
     *     &#x27;identifiers&#x27; if you specify &#x60;variationParentSku&#x60; or &#x60;packageHierarchySku&#x60;.
     *     (optional)
     * @param identifiersType A type of product identifiers that you can use to search for listings items. **Note**:
     *     This is required when &#x60;identifiers&#x60; is provided. (optional)
     * @param variationParentSku Filters results to include listing items that are variation children of the specified
     *     SKU. **Note**: You cannot use &#x60;variationParentSku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;packageHierarchySku&#x60; in your request. (optional)
     * @param packageHierarchySku Filter results to include listing items that contain or are contained by the specified
     *     SKU. **Note**: You cannot use &#x60;packageHierarchySku&#x60; if you include &#x60;identifiers&#x60; or
     *     &#x60;variationParentSku&#x60; in your request. (optional)
     * @param createdAfter A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param createdBefore A date-time that is used to filter listing items. The response includes listings items that
     *     were created at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedAfter A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or after this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param lastUpdatedBefore A date-time that is used to filter listing items. The response includes listings items
     *     that were last updated at or before this time. Values are in [ISO
     *     8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date-time format. (optional)
     * @param withIssueSeverity Filter results to include only listing items that have issues that match one or more of
     *     the specified severity levels. (optional)
     * @param withStatus Filter results to include only listing items that have the specified status. (optional)
     * @param withoutStatus Filter results to include only listing items that don&#x27;t contain the specified statuses.
     *     (optional)
     * @param sortBy An attribute by which to sort the returned listing items. (optional, default to lastUpdatedDate)
     * @param sortOrder The order in which to sort the result items. (optional, default to DESC)
     * @param pageSize The number of results that you want to include on each page. (optional, default to 10)
     * @param pageToken A token that you can use to fetch a specific page when there are multiple pages of results.
     *     (optional)
     * @param callback The callback to be executed when the API call finishes
     * @param restrictedDataToken Restricted Data Token (optional)
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @throws LWAException If calls to fetch LWA access token fails
     */
    public okhttp3.Call searchListingsItemsAsync(
            String sellerId,
            List<String> marketplaceIds,
            String issueLocale,
            List<String> includedData,
            List<String> identifiers,
            String identifiersType,
            String variationParentSku,
            String packageHierarchySku,
            OffsetDateTime createdAfter,
            OffsetDateTime createdBefore,
            OffsetDateTime lastUpdatedAfter,
            OffsetDateTime lastUpdatedBefore,
            List<String> withIssueSeverity,
            List<String> withStatus,
            List<String> withoutStatus,
            String sortBy,
            String sortOrder,
            Integer pageSize,
            String pageToken,
            final ApiCallback<ItemSearchResults> callback,
            String restrictedDataToken)
            throws ApiException, LWAException {

        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressRequestListener = callback::onUploadProgress;
        }

        okhttp3.Call call = searchListingsItemsValidateBeforeCall(
                sellerId,
                marketplaceIds,
                issueLocale,
                includedData,
                identifiers,
                identifiersType,
                variationParentSku,
                packageHierarchySku,
                createdAfter,
                createdBefore,
                lastUpdatedAfter,
                lastUpdatedBefore,
                withIssueSeverity,
                withStatus,
                withoutStatus,
                sortBy,
                sortOrder,
                pageSize,
                pageToken,
                progressRequestListener);

        if (restrictedDataToken != null) {
            okhttp3.Request request = call.request();
            request = RestrictedDataTokenSigner.sign(request, restrictedDataToken, "ListingsApi-searchListingsItems");
            call = apiClient.getHttpClient().newCall(request);
        }

        if (disableRateLimiting || searchListingsItemsBucket.tryConsume(1)) {
            Type localVarReturnType = new TypeToken<ItemSearchResults>() {}.getType();
            apiClient.executeAsync(call, localVarReturnType, callback);
            return call;
        } else throw new ApiException.RateLimitExceeded("searchListingsItems operation exceeds rate limit");
    }

    public static class Builder {
        private LWAAuthorizationCredentials lwaAuthorizationCredentials;
        private String endpoint;
        private LWAAccessTokenCache lwaAccessTokenCache;
        private Boolean disableAccessTokenCache = false;
        private Boolean disableRateLimiting = false;

        public Builder lwaAuthorizationCredentials(LWAAuthorizationCredentials lwaAuthorizationCredentials) {
            this.lwaAuthorizationCredentials = lwaAuthorizationCredentials;
            return this;
        }

        public Builder endpoint(String endpoint) {
            this.endpoint = endpoint;
            return this;
        }

        public Builder lwaAccessTokenCache(LWAAccessTokenCache lwaAccessTokenCache) {
            this.lwaAccessTokenCache = lwaAccessTokenCache;
            return this;
        }

        public Builder disableAccessTokenCache() {
            this.disableAccessTokenCache = true;
            return this;
        }

        public Builder disableRateLimiting() {
            this.disableRateLimiting = true;
            return this;
        }

        public ListingsApi build() {
            if (lwaAuthorizationCredentials == null) {
                throw new RuntimeException("LWAAuthorizationCredentials not set");
            }

            if (StringUtil.isEmpty(endpoint)) {
                throw new RuntimeException("Endpoint not set");
            }

            LWAAuthorizationSigner lwaAuthorizationSigner = null;
            if (disableAccessTokenCache) {
                lwaAuthorizationSigner = new LWAAuthorizationSigner(lwaAuthorizationCredentials);
            } else {
                if (lwaAccessTokenCache == null) {
                    lwaAccessTokenCache = new LWAAccessTokenCacheImpl();
                }
                lwaAuthorizationSigner = new LWAAuthorizationSigner(lwaAuthorizationCredentials, lwaAccessTokenCache);
            }

            return new ListingsApi(
                    new ApiClient()
                            .setLWAAuthorizationSigner(lwaAuthorizationSigner)
                            .setBasePath(endpoint),
                    disableRateLimiting);
        }
    }
}
